import { RouteRecordRaw, createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import Home from "@/views/home/index.vue";
import Layout from "@/layout/index.vue";

export const routes: RouteRecordRaw[] = [
    // {
    //     path: "/",
    //     redirect: "/layout"
    // },
    {
        path: "/",
        // name: "layout",
        component: Layout,
        redirect: "",
        children: [
            {
                path: "",
                component: Home,
                name: "home",
                meta: {
                    title: "首页",
                    keepAlive: true
                }
            },
            {
                path: "/recommend/:id",
                // redirect: "/recommend/:id",
                name: "recommend",
                component: () => import("@/views/recommend/index.vue"),
            },
            {
                path: "oauth",
                children: [
                    {
                        path: "twitter",
                        name: "twitter",
                        component: () => import("@/views/oauth/twitter.vue"),
                    },
                    {
                        path: "google",
                        name: "google",
                        component: () => import("@/views/oauth/google.vue"),
                    }
                ]
            },
            {
                path: "token/:id",
                name: "token",
                component: () => import("@/views/token/index.vue"),
                meta: {
                    title: "链上币种详情",
                    keepAlive: false
                }
            },
            {
                path: "entity/:id",
                component: () => import("@/views/browser/index.vue"),
                name: "entity",
                meta: {
                    title: "浏览器",
                    keepAlive: false
                }
            },
            {
                path: "address/:id",
                component: () => import("@/views/person/index.vue"),
                name: "address",
                meta: {
                    title: "个人",
                    keepAlive: false
                }
            },
            {
                path: "etf",
                component: () => import("@/views/etf/index.vue"),
                name: "etf",
                meta: {
                    title: "EtfsOverView",
                    keepAlive: false
                }
            },
            {
                path: "etfsDetail/:id",
                component: () => import("@/views/etf/detail.vue"),
                name: "etfsDetail",
                meta: {
                    title: "EtfsDetail",
                    keepAlive: false
                }
            },
            {
                path: "commUnity",
                component: () => import("@/views/commUnity/index.vue"),
                name: "commUnity",
                meta: {
                    title: "社区",
                    keepAlive: false
                }
            },
            {
                path: "linkDynamic",
                name: "linkDynamic",
                component: () => import("@/views/linkDynamic/index.vue"),
                children: [
                    {
                        path: "clever",
                        component: () => import("@/views/clever/index.vue"),
                        children: [
                            // {
                            //     path: "cleverCion",
                            //     name: "cleverCion",
                            //     component: () => import("@/views/clever/cleverCoin/index.vue"),
                            //     meta: {
                            //         title: "聪明钱",
                            //         keepAlive: false
                            //     }
                            // },
                            {
                                path: "dateAlter",
                                name: "dateAlter",
                                component: () => import("@/views/clever/dateAlter/index.vue"),
                                meta: {
                                    title: "数据变动",
                                    keepAlive: false
                                }
                            }
                        ]
                    }
                ]
            },
            //暂时用来开发数据异动页面
            {
                path: "clever",
                name: "dateAlter",
                component: () => import("@/views/clever/dateAlter/index.vue"),
                meta: {
                    title: "数据异动",
                    keepAlive: false
                }
            },
            //测试页面
            {
                path: "test",
                name: "test",
                component: () => import("@/views/test/index.vue"),
                meta: {
                    title: "测试",
                    keepAlive: false
                }
            },
            // {
            //     path: "clever",
            //     component: () => import("@/views/clever/index.vue"),
            //     children: [
            //         {
            //             path: "cleverCion",
            //             name: "cleverCion",
            //             component: () => import("@/views/clever/cleverCoin/index.vue"),
            //             meta: {
            //                 title: "聪明钱",
            //                 keepAlive: false,
            //             },
            //         },
            //         {
            //             path: "dateAlter",
            //             name: "dateAlter",
            //             component: () => import("@/views/clever/dateAlter/index.vue"),
            //             meta: {
            //                 title: "数据异动",
            //                 keepAlive: false,
            //             },
            //         }
            //     ]
            // },
            {
                path: "user",
                component: () => import("@/views/user/index.vue"),
                meta: {
                    title: "個人資料",
                    keepAlive: true
                }
            },
            {
                path: "news",
                name: 'news',
                component: () => import("@/views/news/index.vue"),
                meta: {
                    title: "信息",
                    keepAlive: false
                }
            },
            {
                path: "onchain",
                component: () => import("@/views/onChain/index.vue"),
                meta: {
                    title: "链上活动",
                    keepAlive: false
                }
            },

            {
                path: "smartMoney",
                component: () => import("@/views/smartMoney/index.vue"),
                meta: {
                    title: "链上聪明钱",
                    keepAlive: false
                }
            },
            {
                path: "bigVol",
                component: () => import("@/views/bigDeal/index.vue"),
                meta: {
                    title: "大额成交",
                    keepAlive: false
                }
            },
            {
                path: "txn/:id",
                component: () => import("@/views/trading/index.vue"),
                meta: {
                    title: "交易详情",
                    keepAlive: false
                }
            },
            {
                path: "setting",
                component: () => import("@/views/setting/index.vue"),
                meta: {
                    title: "設置",
                    keepAlive: false
                }
            },
            {
                path: "reward",
                name: "reward",
                component: () => import("@/views/reward/index.vue"),
                meta: {
                    title: "獎勵中心",
                    keepAlive: false
                }
            },
            {
                path: "plan",
                component: () => import("@/views/plan/index.vue"),
                meta: {
                    title: "方案",
                    keepAlive: false
                }
            },
            {
                path: "coin/:id",
                name: "coin",
                component: () => import("@/views/coin/index.vue"),
                meta: {
                    title: "详情",
                    keepAlive: false
                }
            },
            {
                path: "ranks",
                component: () => import("@/views/ranks/index.vue"),
                children: [
                    {
                        path: "hot",
                        name: "hot",
                        component: () => import("@/views/ranks/hot/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    },
                    {
                        path: "new",
                        name: "new",
                        component: () => import("@/views/ranks/new/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    },
                    {
                        path: "up",
                        name: "up",
                        component: () => import("@/views/ranks/up/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    },
                    {
                        path: "down",
                        name: "down",
                        component: () => import("@/views/ranks/down/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    },
                    {
                        path: "volatility",
                        name: "volatility",
                        component: () => import("@/views/ranks/volatility/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    },
                    {
                        path: "turnover",
                        name: "turnover",
                        component: () => import("@/views/ranks/turnover/index.vue"),
                        meta: {
                            title: "",
                            keepAlive: false
                        }
                    }
                ]
            }
        ]
    },
    {
        path: "/register",
        component: () => import("@/views/mob/register/index.vue"),
    },
    {
        path: "/registerverify",
        component: () => import("@/views/mob/RegisterVerify.vue"),
    },
    {
        path: "/login",
        component: () => import("@/views/mob/login/index.vue"),
    },
    {
        path: "/loginverify",
        component: () => import("@/views/mob/LoginVerify.vue"),
    },
    {
        path: "/:catchAll(.*)",
        redirect: "/",
    }
];

// console.log("routes==========", routes)

const router = createRouter({
    // history: createWebHashHistory(),
    history: createWebHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        // 始终滚动到顶部
        return { top: 0 };
    }
});

export default router;
